﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using DLL;

namespace BLL
{
  public  class DangNhapBLL
    {
       
      DataServer DB = new DataServer();
      public bool KiemtraDangNhap(string MaNv,string MatKhau)
      {
          string sql = "select MaNv,MatKhau from NhanVien where MaNv=@MaNv and MatKhau=@MatKhau";
          SqlParameter paramMNTB = new SqlParameter("@MaNv", MaNv);
          SqlParameter paramPass = new SqlParameter("@MatKhau", MatKhau);
          DataTable bang = DB.LayDulieu(sql, paramMNTB,paramPass);
          if (bang.Rows.Count > 0)
          {
              return true;
          }
          return false;
      }
      public int LayQuyen(string MaNv, string MatKhau)
      {
        
          string sql = "select Quyen from NhanVien where MaNv=@MaNv and MatKhau=@MatKhau";
          SqlParameter paramMNTB = new SqlParameter("@MaNv", MaNv);
          SqlParameter paramPass = new SqlParameter("@MatKhau", MatKhau);
          DataTable bang = DB.LayDulieu(sql, paramMNTB, paramPass);
          return int.Parse(bang.Rows[0]["Quyen"].ToString());
      }
      public DataTable Select_ALL()
      {
          string sql = "select MaQuyen , TenQuyen from Quyen";
          DataTable bang = DB.LayDulieu(sql);
          return bang;
      }
    }
}
